package com.it.demo012;

public class Cooker extends Thread {
    private Desk desk;
    public Cooker(Desk desk) {
        this.desk = desk;
    }

    @Override
    public void run() {
        while (true){
            synchronized (desk.getLook()){
                if(desk.getCount()==0){
                    break;
                }else {
                    if(!desk.isFlag()){
                        System.out.println("生产");
                        desk.setFlag(true);

                       desk.getLook().notifyAll();
                    }else {
                        try {
                           desk.getLook().wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }
}
